package com.ysx.oa.student.service.impl;

import com.ysx.oa.clazz.bean.ClazzBean;
import com.ysx.oa.student.bean.StudentBean;
import com.ysx.oa.student.dao.StudentDao;
import com.ysx.oa.student.entity.StudentEntity;
import com.ysx.oa.student.service.StudentService;
import com.ysx.oa.teacher.bean.TeacherBean;
import com.ysx.oa.user.bean.UserBean;
import com.ysx.oa.user.dao.UserDao;
import com.ysx.oa.utils.GetDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;
    @Autowired
    private UserDao userDao;


    /*
     * 方法描述:通过ID查找学生的人数
     * @author: 尹泳超
     * @date: 2021/11/23 10:53
     * @params: [studentId]
     * @returns:java.lang.Integer
     */
    @Override
    public Integer countStudentByStudentId(Integer studentId) {
        Integer count = studentDao.countStudentByStudentId(studentId);
        if (count==0){
            return 0;
        }else{
            return count;
        }
    }

    /*
     * 方法描述: 修改学生信息
     * @author: 尹泳超
     * @date:  17:14
     * @params: [id]
     * @returns:java.lang.Integer
     */
    @Override
    public Integer updateStudentMessageByStudentId(UserBean userBean) {

        return userDao.updateByPrimaryKeySelective(userBean);
    }



    /*
     * 方法描述:修改学历
     * @author: 尹泳超
     * @date:  17:15
     * @params: [id]
     * @returns:java.lang.Integer
     */
    @Override
    public Integer updateStudentEducationById(StudentBean studentBean) {
       
        studentBean.setUpdateDate(GetDateTime.nowTime());
        return studentDao.updateByPrimaryKeySelective(studentBean);

    }



    @Override
    public List<UserBean> findStudentListByClassId(Integer classId) {
        return studentDao.findStudentListByClassId(classId);
    }

    @Override
    public ClazzBean findClassByStudentID(Integer studentId) {
        return studentDao.findClassByStudentID(studentId);
    }

    @Override
    public UserBean findTeacherByClassID(Integer classId) {
        return studentDao.findTeacherByClassID(classId);
    }


    @Override
    public StudentEntity findStudentMessageByStudentId(Integer studentId) {
        return studentDao.findStudentMessageByStudentId(studentId);
    }



    /*
     * 方法描述:插入学历
     * @author: 尹泳超
     * @date:  17:14
     * @params: [id]
     * @returns:java.lang.Integer
     */
//    @Override
//    public Integer insertStudentEducationById(Integer id) {
//        StudentBean studentBean=new StudentBean();
//        studentBean.setId(id);
//        studentBean.setCreateDate(GetDateTime.nowTime());
//        return  studentDao.insert(studentBean);
//    }


}
